﻿@page
@model WebApplication3.Pages.MyList.IndexModel

@{
  ViewData["Title"] = "Index";
}

<h2>Index</h2>

<p>
  <a asp-page="Create">Create New</a>
</p>
<div class="row">
  <div class="col-md-4">
    <form method="post">
      <table class="table">
        <thead>
          <tr>
            <th>
              @Html.DisplayNameFor(model => model.DataList[0].Name)
            </th>
            <th>
              @Html.DisplayNameFor(model => model.DataList[0].City)
            </th>
          </tr>
        </thead>
        <tbody id="childtable">
          @for (int i = 0; i < Model.DataList.Count; i++)
          {
            <tr>
              <td>
                <input type="hidden" asp-for="DataList[i].Id" />
                <input asp-for="DataList[i].Name" class="form-control" />
                <span asp-validation-for="DataList[i].Name" class="text-danger"></span>
              </td>
              <td>
                <input asp-for="DataList[i].City" class="form-control" />
                <span asp-validation-for="DataList[i].City" class="text-danger"></span>
              </td>
              <td>
                <input asp-for="DataList[i].Remove" type="checkbox" />
                <label class="control-label">Select</label>
              </td>
            </tr>
          }
        </tbody>
      </table>

      <div class="form-group">
        <input name="command" type="submit" value="Submit" class="btn btn-default" />
      </div>
    </form>
  </div>
</div>

<div>
  <a asp-page="./Index">Back to List</a>
</div>

@section Scripts {
  @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
